import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class TestProgressWidget extends StatefulWidget {
  const TestProgressWidget({super.key});

  @override
  State<StatefulWidget> createState() {
    return ProgressState();
  }
}

class ProgressState extends State<TestProgressWidget> {
  double p = 0.0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text("基础组件 进度指示器 学习使用"),
      ),
      body: SingleChildScrollView(
        scrollDirection: Axis.vertical,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            TextButton(
                onPressed: () {
                  setState(() {
                    p += 0.1;
                    if (p > 1) {
                      p = 1;
                    }
                  });
                },
                child: Text("+")),
            TextButton(
                onPressed: () {
                  setState(() {
                    p -= 0.1;
                    if (p < 0) {
                      p = 0;
                    }
                  });
                },
                child: Text("-")),
            LinearProgressIndicator(
              value: p,
              backgroundColor: Colors.red,
              valueColor: AlwaysStoppedAnimation(Colors.blue),
            ),
            Padding(
              padding: EdgeInsets.only(top: 20.0),
              child: LinearProgressIndicator(
                backgroundColor: Colors.red,
                valueColor: AlwaysStoppedAnimation(Colors.blue),
              ),
            ),
            SizedBox(
              height: 10,
              child: LinearProgressIndicator(
                backgroundColor: Colors.red,
                valueColor: AlwaysStoppedAnimation(Colors.blue),
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 20.0),
              child: CircularProgressIndicator(
                backgroundColor: Colors.red,
                valueColor: AlwaysStoppedAnimation(Colors.blue),
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 20.0),
              child: CircularProgressIndicator(
                value: p,
                backgroundColor: Colors.red,
                valueColor: AlwaysStoppedAnimation(Colors.blue),
              ),
            ),
            SizedBox(
              height: 100,
              child: CircularProgressIndicator(
                backgroundColor: Colors.red,
                valueColor: AlwaysStoppedAnimation(Colors.blue),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
